<template>
    <div>
    <!--提醒开始-->
    <!--每天-->
    <a-modal
            :visible="visible7"
            :confirm-loading="confirmLoading7"
            width="300px"
            @ok="handleOk7"
            @cancel="handleCancel7"
    >
        <a-select
                label-in-value
                :default-value="{ key: '1' }"
                style="width: 100%"
        >
            <a-select-option value="1">
                到期重复
            </a-select-option>
        </a-select>
        <div style="margin-top: 10px; margin-bottom: 10px;">
            <span
                    style="text-align: center; display: inline-block;width: 120px;height:30px;line-height:30px;border: 1px solid #CCCCCC;border-radius: 5px;">每 1</span>
            <j-dict-select-tag
                    style="width: 120px;float:right;"
                    :fristValue="true"
                    v-model="remindRepeat.nrtType"
                    placeholder="请选择类型"
                    dictCode="note_remind_tzyn"
                    change="nrtTypeOnChange"
                    @input="nrtTypeOnChange"/>

        </div>
        <div id="week" v-show="remindRepeat.nrtType==2">
            <span :class="{weekActive:remindRepeat.nrtValueArr[7]==1}" @click="weekSelect(7)">日</span>
            <span :class="{weekActive:remindRepeat.nrtValueArr[1]==1}" @click="weekSelect(1)">一</span>
            <span :class="{weekActive:remindRepeat.nrtValueArr[2]==1}" @click="weekSelect(2)">二</span>
            <span :class="{weekActive:remindRepeat.nrtValueArr[3]==1}" @click="weekSelect(3)">三</span>
            <span :class="{weekActive:remindRepeat.nrtValueArr[4]==1}" @click="weekSelect(4)">四</span>
            <span :class="{weekActive:remindRepeat.nrtValueArr[5]==1}" @click="weekSelect(5)">五</span>
            <span :class="{weekActive:remindRepeat.nrtValueArr[6]==1}" @click="weekSelect(6)">六</span>
        </div>

        <div v-show="remindRepeat.nrtType==3">
            <div style="clear:both;line-height: 50px;">
              <span style="width: 80px;display: inline-block;" :class="{ moneyActive:remindRepeat.nrtValue2==1}"
                    @click="()=>{remindRepeat.nrtValue2 = 1;}">按日期</span>
                <span style="width: 80px;display: inline-block;" :class="{ moneyActive:remindRepeat.nrtValue2==2}"
                      @click="()=>{remindRepeat.nrtValue2 = 2;}">按星期</span>
                <span style="width: 80px;display: inline-block;float:right;"
                      :class="{ moneyActive:remindRepeat.nrtValue2==3}"
                      @click="()=>{remindRepeat.nrtValue2 = 3;}">按工作日</span>
            </div>
            <my-calendar-date v-if="remindRepeat.nrtValue2==1" :selectDate="remindRepeat.nrtValueArr3" @chose="clickDay"/>
            <div v-if="remindRepeat.nrtValue2==2">
                <a-select
                        @change="remindValue4Change"
                        style="width: 120px"
                        v-model="remindRepeat.nrtValue4"
                >
                    <a-select-option v-for="count in repeatCount" :key="count.key" :value="count.key">{{count.data}}</a-select-option>
                </a-select>

                <j-dict-select-tag
                        :fristValue="true"
                        style="width: 120px;float:right;"
                        v-model="remindRepeat.nrtValue5"
                        placeholder="请选择类型"
                        dictCode="note_remind_week"
                />
            </div>

            <div v-if="remindRepeat.nrtValue2==3">
                <a-select
                        style="width: 100%"
                        @change="remindValue6Change"
                        v-model="remindRepeat.nrtValue6"
                >
                    <a-select-option v-for="work in repeatWork" :key="work.key" :value="work.key">{{work.data}}</a-select-option>
                </a-select>
            </div>
        </div>

        <div v-show="remindRepeat.nrtType==4">
            <j-dict-select-tag
                    style="width: 100%;"
                    :fristValue="true"
                    v-model="remindRepeat.nrtValue7"
                    placeholder="请选择类型"
                    dictCode="note_remind_year"
                    change="nrtTypeOnChange"
                    @input="nrtTypeOnChange"/>
            <a-select
                    @change="remindValue4Change"
                    style="width: 120px"
                    v-model="remindRepeat.nrtValue4"
            >
                <a-select-option v-for="count in repeatCount" :key="count.key" :value="count.key">{{count.data}}</a-select-option>
            </a-select>

            <j-dict-select-tag
                    style="width: 120px;float:right;"
                    :fristValue="true"
                    v-model="remindRepeat.nrtValue5"
                    placeholder="请选择类型"
                    dictCode="note_remind_week"
            />

        </div>

        <div style="margin-top: 10px;">
            <a-checkbox>跳过法定节假日</a-checkbox>
        </div>
        <div>
            <a-checkbox >跳过双休日</a-checkbox>
        </div>

    </a-modal>
    <!--    按次数结束    -->
    <a-modal
            :visible="visible4"
            :confirmLoading="confirmLoading4"
            width="275px"
            closeIcon=""
            @ok="handleOk4"
            @cancel="handleCancel4"
    >
        <template slot="footer">
            <a-button @click="handleCancel4" style="width: 85px; float: left;margin-left: 30px;">取消</a-button>
            <a-button type="primary" @click="handleOk4" style="width: 85px; margin-right: 30px;">确定</a-button>
        </template>

        <a-input style="width: 100px;" v-model="remindStop.tempCount"/>
        <span style="text-align: center;width: 100px;display: inline-block">次后结束</span>

    </a-modal>
    <!--准时弹窗-->
    <a-modal
            :visible="visible3"
            :confirmLoading="confirmLoading3"
            width="275px"
            closeIcon=""
            @ok="handleOk3"
            @cancel="handleCancel3"
    >
        <template slot="footer">
            <a-button @click="handleCancel3" style="width: 85px; float: left;margin-left: 30px;">取消</a-button>
            <a-button type="primary" @click="handleOk3" style="width: 85px; margin-right: 30px;">确定</a-button>
        </template>

        <div style="width: 200px;">
            <div style="margin-bottom: 10px;">
                <a-input style="width: 150px;" v-model="remindRelative.day"/>
                <span style="width: 50px; display: inline-block;text-align: center;">天</span>
            </div>
            <div style="margin-bottom: 10px;">
                <a-input style="width: 50px;" v-model="remindRelative.hour"/>
                <span style="width: 50px;display: inline-block;text-align: center;">小时</span>
                <a-input style="width: 50px;" v-model="remindRelative.minute"/>
                <span style="width: 50px;display: inline-block;text-align: center;">分钟</span>
            </div>
            <span>提前
                <span>{{remindRelative.day}}天</span>
                <span>{{remindRelative.hour}}小时</span>
                {{remindRelative.minute}}分钟
                <!--              于{{date}}提醒-->
              </span>
        </div>

    </a-modal>
    <a-modal
            :visible="visible"
            :confirm-loading="confirmLoading"
            width="275px"
            closeIcon=""
            @ok="handleOk"
            @cancel="()=>{this.visible = false;}"
    >
        <template slot="footer">
            <a-button @click="handleCancel" style="width: 85px; float: left;margin-left: 30px;">清除</a-button>
            <a-button type="primary" @click="handleOk" style="width: 85px; margin-right: 30px;">确定</a-button>
        </template>

        <a-card
                style="width:100%"
                :tab-list="tabListNoTitle"
                :bordered="false"
                :active-tab-key="noTitleKey"
                @tabChange="key => rightOnTabChange(key, 'noTitleKey')"
        >
            <div v-if="noTitleKey === 'date'">
                <a-date-picker style="width:180px;margin-bottom: 10px; border-color: #00A0E9;" @change="rightDateOnChange"
                               v-model="tempStartDate"/>
                <a-time-picker style="width:180px;margin-bottom: 10px;" format="HH:mm" @change="rightTimeOnChange"
                               v-model="tempStartTime"/>
                <a-button
                        style="width:180px;margin-bottom: 10px;"
                        :class="{'actionBtn':this.remindRelative.hour>0||this.remindRelative.minute>0||this.remindRelative.day>0}"
                        @click="showRemindRelative">
                    <div v-if="remindRelative.day>0||remindRelative.hour>0||remindRelative.minute>0">
                        提前
                        <span v-show="remindRelative.day>0">{{remindRelative.day}}天</span>
                        <span v-show="remindRelative.hour>0">{{remindRelative.hour}}小时</span>
                        <span v-show="remindRelative.minute>0">{{remindRelative.minute}}分钟</span>
                        提醒
                    </div>
                    <span v-else>准时</span>
                </a-button>
                <a-button style="width:180px;margin-bottom: 10px;" :class="{'actionBtn':this.note.nn_repeat}"
                          @click="showRemindRepeat">每{{repeatType[remindRepeat.nrtType-1]}}
                    <span v-show="remindRepeat.nrtType==2">
                  <span v-for="(week,index) in remindRepeat.nrtValueArr" v-show="week==1">{{repeatWeek[index-1]}}</span>
                </span>
                    <span v-show="remindRepeat.nrtType==3">
                  <span v-show="remindRepeat.nrtValue2==1" v-for="(day,index) in remindRepeat.nrtValueArr3">
                    {{day.date.split("/")[2]}}号
                  </span>
                  <span v-show="remindRepeat.nrtValue2==2">
                    {{repeatCount[remindRepeat.nrtValue4-1]&&repeatCount[remindRepeat.nrtValue4-1].data}}
                    {{repeatWeek[remindRepeat.nrtValue5-1]}}
                  </span>
                  <span v-show="remindRepeat.nrtValue2==3" >
                    {{repeatWork[remindRepeat.nrtValue6-1]&&repeatWork[remindRepeat.nrtValue6-1].data}}
                  </span>
                </span>
                    <span v-show="remindRepeat.nrtType==4">
                  <span>{{remindRepeat.nrtValue7}}月</span>
                  <span >
                    {{repeatCount[remindRepeat.nrtValue4-1]&&repeatCount[remindRepeat.nrtValue4-1].data}}
                    {{repeatWeek[remindRepeat.nrtValue5-1]}}
                  </span>
                </span>
                </a-button>
                <a-dropdown>
                    <a-menu slot="overlay" @click="handleMenuClick">
                        <!--                <a-menu-item key="0"> 选择重复</a-menu-item>-->
                        <a-menu-item key="1"> 一直重复</a-menu-item>
                        <a-menu-item key="2">
                            <a-date-picker style="width:100%;" v-model="remindStop.tempDate"
                                           @change="rightRepetitionDateOnChange">
                                <span>按日期结束重复</span>
                            </a-date-picker>
                        </a-menu-item>
                        <a-menu-item key="3"> 按次数结束重复</a-menu-item>
                    </a-menu>
                    <a-button style="width:180px;"> {{repetitionList[remindStop.nrsType].value}}</a-button>
                </a-dropdown>
            </div>

            <div v-else-if="noTitleKey === 'time'">
                <span>开始</span>
                <div style="margin-bottom: 10px;">
                    <a-date-picker size="small" style="width: 105px;" v-model="tempStartDate"/>
                    <a-time-picker size="small" style="width: 70px;"  v-model="tempStartTime" format="HH:mm"/>
                </div>
                <span>结束</span>
                <div style="margin-bottom: 10px;">
                    <a-date-picker size="small" style="width: 105px;"/>
                    <a-time-picker size="small" style="width: 70px;" format="HH:mm"/>
                </div>
                <a-button
                        style="width:180px;margin-bottom: 10px;"
                        :class="{'actionBtn':this.remindRelative.hour>0||this.remindRelative.minute>0||this.remindRelative.day>0}"
                        @click="showRemindRelative">
                    <div v-if="remindRelative.day>0||remindRelative.hour>0||remindRelative.minute>0">
                        提前
                        <span v-show="remindRelative.day>0">{{remindRelative.day}}天</span>
                        <span v-show="remindRelative.hour>0">{{remindRelative.hour}}小时</span>
                        <span v-show="remindRelative.minute>0">{{remindRelative.minute}}分钟</span>
                        提醒
                    </div>
                    <span v-else>准时</span>
                </a-button>
                <a-button style="width:180px;margin-bottom: 10px;" :class="{'actionBtn':this.note.nn_repeat}"
                          @click="showRemindRepeat">每{{repeatType[remindRepeat.nrtType-1]}}
                    <span v-show="remindRepeat.nrtType==2">
                  <span v-for="(week,index) in remindRepeat.nrtValueArr" v-show="week==1">{{repeatWeek[index-1]}}</span>
                </span>
                    <span v-show="remindRepeat.nrtType==3">
                  <span v-show="remindRepeat.nrtValue2==1" v-for="(day,index) in remindRepeat.nrtValueArr3">
                    {{day.date.split("/")[2]}}号
                  </span>
                  <span v-show="remindRepeat.nrtValue2==2">
                    {{repeatCount[remindRepeat.nrtValue4-1]&&repeatCount[remindRepeat.nrtValue4-1].data}}
                    {{repeatWeek[remindRepeat.nrtValue5-1]}}
                  </span>
                  <span v-show="remindRepeat.nrtValue2==3" >
                    {{repeatWork[remindRepeat.nrtValue6-1]&&repeatWork[remindRepeat.nrtValue6-1].data}}
                  </span>
                </span>
                    <span v-show="remindRepeat.nrtType==4">
                  <span>{{remindRepeat.nrtValue7}}月</span>
                  <span >
                    {{repeatCount[remindRepeat.nrtValue4-1]&&repeatCount[remindRepeat.nrtValue4-1].data}}
                    {{repeatWeek[remindRepeat.nrtValue5-1]}}
                  </span>
                </span>
                </a-button>
                <a-dropdown>
                    <a-menu slot="overlay" @click="handleMenuClick">
                        <!--                <a-menu-item key="0"> 选择重复</a-menu-item>-->
                        <a-menu-item key="1"> 一直重复</a-menu-item>
                        <a-menu-item key="2">
                            <a-date-picker style="width:100%;" v-model="remindStop.tempDate"
                                           @change="rightRepetitionDateOnChange">
                                <span>按日期结束重复</span>
                            </a-date-picker>
                        </a-menu-item>
                        <a-menu-item key="3"> 按次数结束重复</a-menu-item>
                    </a-menu>
                    <a-button style="width:180px;"> {{repetitionList[remindStop.nrsType].value}}</a-button>
                </a-dropdown>

            </div>
        </a-card>
    </a-modal>
    <!--提醒结束-->
    </div>
</template>

<script>
    let repeatWorkList = [];
    for(let i = 1;i<=30;i++){
        repeatWorkList.push({key:i+'',data:`第`+i+`个工作日`});
    }

    export default {
        name: "Remind",
        props: {
            note:{
                type: Object,
                default: ''
            },
        },
        data(){
            return {
                success: false,
                visible: false,//紧急程度
                visible2: false,//时间准时提示
                visible3: false,//时间准时自定义提示,
                visible4: false,//按次数结束,
                visible7: false,//每天,
                confirmLoading: false,
                confirmLoading2: false,
                confirmLoading3: false,
                confirmLoading4: false,
                confirmLoading7: false,
                tempStartDate: null,
                tempStartTime: null,
                endDate: null,
                endTime: null,
                punctualityList: [
                    // {key:1,text:"无",value:0},
                    {key: 2, text: "准时", value: 0},
                    {key: 3, text: "提前 5 分钟", value: 1000 * 60 * 5},
                    {key: 4, text: "提前 30 分钟", value: 1000 * 60 * 30},
                    {key: 5, text: "提前 1 小时", value: 1000 * 60 * 60},
                    {key: 6, text: "提前 1 天", value: 1000 * 60 * 60 * 24},
                ],
                //重复
                repetitionList: [
                    {key: 0, value: "选择重复"},
                    {key: 1, value: "一直重复"},
                    {key: 2, value: "按日期结束重复"},
                    {key: 3, value: "按次数结束重复"},
                ],
                //时间提示弹窗的卡片
                tabListNoTitle: [
                    {
                        key: 'date',
                        tab: '日期',
                    },
                    {
                        key: 'time',
                        tab: '时间段',
                    },
                ],
                key: 'tab1',
                noTitleKey: 'date',
                //准时
                remindRelative: {
                    nrrId: null,
                    nn_id: null,
                    nrrValue: null,//整数提前，负数延后提示

                    //准时提前,  ---交给后端后，将其转为时间字段提交到数据库
                    day: 0,
                    hour: 0,
                    minute: 0,
                },
                //执行的添加
                remindRepeat: {
                    nrtId: null,
                    nn_id: null,
                    nrtType: null,//类型【1：每天；2：每周；3：每月；4：每年】
                    nrtIsChinaCalendar: null,//是否农历
                    nrtValueArr: [0, 0, 0, 0, 0, 0, 0, 0],//一周七天，1-7
                    nrtValue2: 1,//时间提示  --  按月份时的=》按日期、按星期、按工作日
                    nrtValueArr3: [],//每月哪几天
                    nrtValue4: null,//每月（每年）的第n个星期
                    nrtValue5: null,//每月（每年）某周，的星期几 1-7
                    nrtValue6: null,//某月第几个工作日
                    nrtValue7: null,//每年第几月份
                },
                //结束条件
                remindStop: {
                    nrsId: null,
                    nn_id: null,
                    nrsType: 0,//类型【1：一直重复；2：到期终止；3：到次终止】
                    nrsValue: null,//重复值(填写日期；填写次数）

                    tempDate: null,
                    tempCount: null,
                },repeatType: [
                    "天",
                    "周",
                    "月",
                    "年",
                ],
                repeatWeek: [
                    "周一",
                    "周二",
                    "周三",
                    "周四",
                    "周五",
                    "周六",
                    "周日",
                ],
                repeatCount: [
                    {key:"1",data:"第一个"},
                    {key:"2",data:"第二个"},
                    {key:"3",data:"第三个"},
                    {key:"4",data:"第四个"},
                    {key:"5",data:"第五个"},
                ],
                repeatWork:repeatWorkList,
            }
        },
        methods: {
            remindValue6Change(value) {
                this.remindRepeat.nrtValue6 = value;
                console.log("选择value6=》 ", this.remindRepeat.nrtValue6)
            },
            remindValue4Change(value) {
                this.remindRepeat.nrtValue4 = value;
                console.log("选择value4=》 ", this.remindRepeat.nrtValue4)
            },
            //一个月提醒的天数
            clickDay(today) {//选中日期
                // today格式为2020/8/7 改为 20200807
                console.log("当前选中日期===>", today);
                let existDate = this.remindRepeat.nrtValueArr3;
                let isExist = true;
                for (let i = 0; i < existDate.length; i++) {
                    if (existDate[i].date === today) {
                        console.log("当前日期存已在===>", today);
                        this.remindRepeat.nrtValueArr3.splice(i, 1);
                        isExist = false;
                    }
                }
                if (isExist) {//当前日期存在移除
                    console.log("不存在-添加===>");
                    let tempDate = {date: today, className: "mark1"}
                    this.remindRepeat.nrtValueArr3.push(tempDate)
                }
                console.log("this.selectDate===>", JSON.stringify(this.remindRepeat.nrtValueArr3));
            },
            //一周提醒的天数
            weekSelect(index) {
                Vue.set(this.remindRepeat.nrtValueArr, index, this.remindRepeat.nrtValueArr[index] == 1 ? 0 : 1);
                console.log("weekSelect", this.remindRepeat.nrtValueArr)
            },
            //打开提示弹窗时执行
            showRemind() {


                this.visible = true;
                postAction(`note/queryRemind/${this.note.nn_id}`).then(res=>{
                    console.log("提醒功能 =》》 ",res)
                    if(res.success==true){
                        if (res.result.remindRelative != null) {
                            this.remindRelative = res.result.remindRelative;
                        }
                        if (res.result.remindRepeat != null) {
                            this.remindRepeat = res.result.remindRepeat;
                        }
                        if(res.result.remindStop==null){
                            this.deleteRemindStop();
                        }else{
                            this.remindStop = res.result.remindStop;
                            if (this.remindStop.nrsType == 2) {
                                this.remindStop.tempDate = this.$moment(this.remindStop.nrsValue);
                            } else if (this.remindStop.nrsType == 3) {
                                this.remindStop.tempCount = this.remindStop.nrsValue;
                            }
                        }
                    }else{
                        this.$message.warning("请求失败")
                    }
                }).catch(error=>{
                    this.$message.warning("提醒请求异常")
                })

                // this.queryNeRemindRelativeByNoteId();
                // this.queryNeRemindStopByNoteId();
                // this.queryNeRemindRepeatByNoteId();
            },
            showRemindRepeat() {
                if (this.tempStartDate == null) {
                    this.$message.warning("请选择日期后，再选准时")
                    return;
                }
                this.visible7 = true;

            },//选准时
            showRemindRelative() {
                if (this.tempStartDate == null) {
                    this.$message.warning("请选择日期后，再选准时")
                    return;
                }
                this.visible3 = true;
                // this.queryNeRemindRelativeByNoteId(() => {
                //
                // });
            },
            queryNeRemindRepeatByNoteId() {
                postAction(`remind/repeat/queryNeRemindRepeatByNoteId/${this.note.nn_id}`).then(res => {
                    console.log("remindrepeat", res);
                    if (res.success == true) {
                        if (res.result != null) {
                            this.remindRepeat = res.result;
                        } else {
                            this.$message.warning("请求异常")
                        }
                    }
                })
            },
            queryNeRemindRelativeByNoteId(backcall) {
                postAction(`remind/relative/queryNeRemindRelativeByNoteId/${this.note.nn_id}`).then(res => {
                    console.log("提醒准时",res)
                    if (res.success == true) {
                        if (res.result != null) {
                            this.remindRelative = res.result;
                        }
                        backcall && backcall();
                    } else {
                        this.$message.warning("代码异常异常")
                    }
                })
            },
            queryNeRemindStopByNoteId(backcall) {
                postAction(`remind/stop/queryNeRemindStopByNoteId/${this.note.nn_id}`).then(res => {
                    console.log("stop", res)
                    if (res.success == true) {
                        if (res.result == null) {
                            this.deleteRemindStop();
                        } else {
                            this.remindStop = res.result;
                            if (this.remindStop.nrsType == 2) {
                                this.remindStop.tempDate = this.$moment(this.remindStop.nrsValue);
                            } else if (this.remindStop.nrsType == 3) {
                                this.remindStop.tempCount = this.remindStop.nrsValue;
                            }
                        }
                        backcall && backcall();
                    } else {
                        this.$message.warning("请求异常")
                    }
                })
            },
            //开启全天
            allDayOnChange(checked) {
                console.log(`a-switch to ${checked}`);
            },
            //多选日期切换 月份
            changeDate(data) {
                console.log("changeDate", data); //左右点击切换月份
            },

            //重复选择
            handleMenuClick(e) {
                this.remindStop.nrsType = e.key;
                if (e.key == 3) {
                    this.visible4 = true;
                }
            },

            //准时提醒（一直重复）确定
            handleOk4(e) {
                if (!this.confirmLoading4) {
                    console.log("提交")
                    this.confirmLoading4 = true;
                    setTimeout(() => {
                        this.visible4 = false;
                        this.confirmLoading4 = false;
                    }, 500);
                }
            },
            //准时提醒（一直重复）取消
            handleCancel4(e) {
                this.visible4 = false;
            },

            //准时自定义提醒时间确定
            handleOk3(e) {
                this.visible3 = false;
                // if (!this.confirmLoading3) {
                //     this.confirmLoading3 = true;
                //     //计算天、小时、分钟  =》 毫秒
                //     this.remindRelative.nrrValue = this.remindRelative.day * 24 * 60 * 60 * 1000 + this.remindRelative.hour * 60 * 60 * 1000 + this.remindRelative.minute * 60 * 1000;
                //     console.log(this.remindRelative.nrrValue)
                //
                //     this.remindRelative.nn_id = this.note.nn_id
                //
                //     postAction(`/remind/relative/save`, this.remindRelative).then(res => {
                //         console.log("remind", res);
                //         if (res.success == true) {
                //             this.remindRelative.nrrId = res.result.nrrId;
                //             this.date = this.$moment(new Date(new Date(this.note.nn_start_time).getTime() - parseInt(this.remindRelative.nrrValue))).format("YYYY年MM月DD日 HH时:mm分钟")
                //             this.$message.success("保存成功！")
                //             this.visible3 = false;
                //             this.confirmLoading3 = false;
                //         } else {
                //             this.$message.error("保存失败！")
                //             this.confirmLoading3 = false;
                //         }
                //     }).catch(err => {
                //         this.confirmLoading3 = false;
                //     })
                //
                // }
            },
            //准时自定义提醒时间取消
            handleCancel3(e) {
                this.visible3 = false;
            },
            deleteRemindRelative() {
                console.log("清除Relative")
                this.remindRelative.day = 0;
                this.remindRelative.hour = 0;
                this.remindRelative.minute = 0;
                this.remindRelative.nrrValue = 0;
            },
            deleteRemindRepeat() {
                console.log("清除Repeat")
                this.remindRepeat.nrtId = null;
                this.remindRepeat.nn_id = null;
                this.remindRepeat.nrtType = null;//类型【1：每天；2：每周；3：每月；4：每年】
                this.remindRepeat.nrtIsChinaCalendar = null;//是否农历
                this.remindRepeat.nrtValueArr = [0, 0, 0, 0, 0, 0, 0, 0];//一周七天，1-7
                this.remindRepeat.nrtValue2 = 1;//时间提示  --  按月份时的=》按日期、按星期、按工作日
                this.remindRepeat.nrtValueArr3 = [];//每月哪几天
                this.remindRepeat.nrtValue4 = null;//每月（每年）的第n个星期
                this.remindRepeat.nrtValue5 = null;//每月（每年）某周，的星期几 1-7
                this.remindRepeat.nrtValue6 = null;//某月第几个工作日
                this.remindRepeat.nrtValue7 = null;//每年第几月份
            },
            deleteRemindStop() {
                console.log("清除Stop")
                this.remindStop.nrsType = 0;
                this.remindStop.nn_id = this.note.nn_id;
                this.remindStop.nrsId = null;
                this.remindStop.nrsValue = null;
                this.remindStop.tempDate = null;
                this.remindStop.tempCoun = null;
            },
            //准时提醒时间
            // punctualityClick(val){
            //     this.remindRelative.nnPunctualityKey = val;
            //     console.log(this.remindRelative.nnPunctualityKey);
            //     this.visible3=true;
            //     if(val!=0){
            //         this.visible3=false;
            //         this.remindRelative.nrrValue = this.punctualityList[val-1].value;
            //
            //         let num = this.remindRelative.nrrValue/1000;
            //         this.remindRelative.day = parseInt(num/60/60/24);
            //         this.remindRelative.hour = parseInt(num/60/60)%24;
            //         this.remindRelative.minute = (num/60)%60;
            //     }
            //     console.log("延迟的timer=》 ",this.remindRelative.nrrValue);
            //     console.log(this.remindRelative.day+"天："+this.remindRelative.hour+"小时："+this.remindRelative.minute+"分钟：")
            // },
            //准时提醒时间确定
            // handleOk2(e) {
            //     if(!this.confirmLoading2){
            //         this.confirmLoading2 = true;
            //         //提交
            //         console.log("准时=》  ",this.remindRelative)
            //         postAction(`/remind/relative/save`,this.remindRelative).then(res=>{
            //             console.log("remind",res);
            //             if(res.success==true){
            //                 this.$message.success("保存成功！")
            //                 this.visible2 = false;
            //                 this.confirmLoading2 = false;
            //             }else{
            //                 this.$message.error("保存失败！")
            //             }
            //         })
            //     }
            // },
            //准时提醒时间取消
            // handleCancel2(e) {
            //     this.visible2 = false;
            //     this.remindRelative.nnPunctualityKey = 1;
            // },

            //按日期结束
            rightRepetitionDateOnChange(date, dateString) {
                if (this.tempStartDate == null) {
                    this.$message.warning("请选择日期后，再选按日期结束")
                    return;
                }
                console.log("日期=》 ", dateString);
                let time = new Date(dateString).getTime();
                let startTime = new Date(this.tempStartDate).getTime();
                console.log(startTime, time)
                if (startTime >= time) {
                    this.$message.warning("按日期结束的日期必须是开始日期后面")
                    return;
                }
                this.endDate = dateString;
            },
            //提示日期
            rightDateOnChange(date, dateString) {
                // this.tempStartDate = dateString;
                console.log("日期=》 ", this.tempStartDate);
            },
            //提示时间
            rightTimeOnChange(date, dateString) {
                // this.tempStartTime = dateString;
                console.log("时间=》 ", this.tempStartTime);
            },
            //提醒时间卡片
            rightOnTabChange(key, type) {
                console.log(key, type);
                this[type] = key;
            },
            nrtTypeOnChange(val) {
                console.log("每天、周、月、年 =》 ", val);
            },
            deleteNeRemindRelativeByNoteId(backcall) {
                postAction(`remind/relative/deleteNeRemindRelativeByNoteId/${this.note.nn_id}`).then(res => {
                    if (res.success == true) {
                        backcall && backcall();
                    } else {

                    }
                })
            },
            deleteRemindStopByNoteId(backcall) {
                postAction(`remind/stop/deleteRemindStopByNoteId/${this.note.nn_id}`).then(res => {
                    if (res.success == true) {
                        backcall && backcall();
                    } else {

                    }
                })
            },
            deleteNeRemindRepeatByNoteId(backcall) {
                postAction(`remind/repeat/deleteNeRemindRepeatByNoteId/${this.note.nn_id}`).then(res => {
                    if (res.success == true) {
                        backcall && backcall();
                    } else {

                    }
                })
            },
            //将yyyy-mm-dd转为yyyy年mm月dd日
            convertDate(data) {
                if (data != null) {
                    let timeSplit = data.split(" ");
                    let date = timeSplit[0].split("-");
                    let dateString = date[0] + "年" + date[1] + "月" + date[2] + "日";
                    return dateString;
                }
                return null;
            },
            //紧急程度取消
            handleCancel(e) {
                // this.tempStartDate = null;
                // this.tempStartTime = null;
                //清除remindStop和remindRelative
                postAction(`cron/close/${this.note.nn_id}`).then(res=>{
                    if(res.success==true){
                        this.visible = false;
                    }
                })
                // this.deleteNeRemindRelativeByNoteId(this.deleteRemindRelative);
                // this.deleteNeRemindRepeatByNoteId(this.deleteRemindRepeat);
                // this.deleteRemindStopByNoteId(this.deleteRemindStop);
            },
            //紧急程度确定
            handleOk(e) {
                if (!this.confirmLoading) {
                    this.confirmLoading = true;

                    //如果有选择时间（时分秒），则添加到时间上
                    if (this.tempStartDate != null && this.tempStartDate != "") {
                        this.note.nn_start_time = this.$moment(this.tempStartDate).format("YYYY-MM-DD");
                        if (this.tempStartTime != null && this.tempStartTime != "") {
                            this.note.nn_start_time += " " + this.$moment(this.tempStartTime).format("HH:mm");
                        }
                        console.log("选中时间=》 ", this.note.nn_start_time)
                    }else{
                        this.note.nn_start_time = null;
                    }

                    this.remindRelative.nn_id = this.note.nn_id;
                    this.remindRepeat.nn_id = this.note.nn_id;
                    this.remindStop.nn_id = this.note.nn_id;
                    if (this.remindStop.nrsType == 2) {
                        this.remindStop.nrsValue = this.$moment(this.remindStop.tempDate).format("YYYY-MM-DD");
                    } else if (this.remindStop.nrsType == 3) {
                        this.remindStop.nrsValue = this.remindStop.tempCount;
                    }

                    this.note.remindRelative = this.remindRelative;
                    this.note.remindRepeat = this.remindRepeat;
                    this.note.remindStop = this.remindStop;

                    console.log("保存note=》 ",this.note)

                    postAction("note/saveRemind",this.note).then(res=>{
                        if(res.success==true){
                            this.remindRelative.nrrId = res.result.nrrId;
                            if(this.note.nn_start_time!=null&&this.note.nn_start_time!=''){
                                if(this.remindRelative.nrrValue!=null&&this.remindRelative.nrrValue!=''){
                                    this.date = this.$moment(new Date(new Date(this.note.nn_start_time).getTime() - parseInt(this.remindRelative.nrrValue))).format("YYYY年MM月DD日 HH时:mm分钟")
                                }else{
                                    this.date = this.$moment(new Date(new Date(this.note.nn_start_time).getTime())).format("YYYY年MM月DD日 HH时:mm分钟")
                                }
                            }else{
                                this.date = "时间提醒"
                            }

                            this.remindRepeat.nrtId = res.result.nrtId;

                            this.remindStop.nrsId = res.result.nrsId

                            this.confirmLoading = false;
                            this.visible = false;
                        }else{
                            this.confirmLoading = false;
                            this.$message.warning("请求发生错误！")
                        }

                    }).catch(error=>{
                        this.confirmLoading = false;
                        this.visible = false;
                    })
                }
            },
            //标签树取消
            handleCancel7(e) {
                this.visible7 = false;
            },
            //标签树确定
            handleOk7(e) {
                this.visible7 = false;
                // this.remindRepeat.nn_id = this.note.nn_id;
                // console.log("保存提醒重复条件=> ", this.remindRepeat);
                // postAction("/remind/repeat/save", this.remindRepeat).then(res => {
                //     if (res.success == true) {
                //         this.$message.success('保存成功！');
                //         this.remindRepeat.nrtId = res.result.nrtId;
                //         this.visible7 = false;
                //         console.log("保存成功=> ", this.remindRepeat);
                //     } else {
                //         this.$message.warning("保存失败");
                //     }
                // })
            },
        }
    }
</script>

<style scoped>

</style>